Skip to content

fix(pty): use proper process tree cleanup on disposal#5876

Closed
anntnzrb wants to merge 1 commit intoanomalyco:devfrom
anntnzrb:fix/pty-process-cleanup
Closed

fix(pty): use proper process tree cleanup on disposal#5876
anntnzrb wants to merge 1 commit intoanomalyco:devfrom
anntnzrb:fix/pty-process-cleanup

Conversation

@anntnzrb
Copy link
Contributor

Summary

  • Add killPtyTree() helper for proper PTY process tree cleanup
  • Use Promise.all() for parallel session cleanup on disposal

Problem

PTY disposal was using process.kill() directly which:

  • Only sends SIGTERM without SIGKILL escalation
  • Doesn't kill child processes spawned by the shell
  • Doesn't handle Windows process trees

Solution

Added killPtyTree() helper (based on Shell.killTree pattern) that:

  • Kills the process group (-pid) on Unix
  • Escalates to SIGKILL after 200ms if needed
  • Uses taskkill /t on Windows for tree kill
  • Properly catches errors for already-exited processes

Related: #3057, #5525

PTY disposal was using process.kill() directly which:
- Only sends SIGTERM without SIGKILL escalation
- Doesn't kill child processes spawned by the shell
- Doesn't handle Windows process trees

Added killPtyTree() helper (based on Shell.killTree pattern) that:
- Kills the process group (-pid)
- Escalates to SIGKILL after 200ms if needed
- Uses taskkill /t on Windows for tree kill
- Uses Promise.all for parallel cleanup of multiple sessions
- Properly catches errors for already-exited processes
@github-actions
Copy link
Contributor

Closing this pull request because it has had no updates for more than 60 days. If you plan to continue working on it, feel free to reopen or open a new PR.

@github-actions github-actions bot closed this Feb 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments